home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / Amiga_Mail_Vol1 / Audio / PALAudio < prev    next >
Encoding:
Text File  |  1999-10-27  |  1.3 KB  |  39 lines

  1. (c)  Copyright 1989-1999 Amiga, Inc.   All rights reserved.
  2. The information contained herein is subject to change without notice, and 
  3. is provided "as is" without warranty of any kind, either expressed or implied.  
  4. The entire risk as to the use of this information is assumed by the user.
  5.  
  6.  
  7.  
  8.                            PAL and Audio 
  9.  
  10.                          Carolyn Scheppner
  11.  
  12.  
  13.      To generate accurate frequencies on both NTSC and PAL Amigas, audio 
  14. programs that calculate periods from a given frequency must use the 
  15. appropriate clock constant on each machine.  Programs can determine if they 
  16. are running on an NTSC or PAL machine by checking GfxBase->DisplayFlags for
  17. the PAL or NTSC flags defined in gfxbase.h.  The clock constants for period 
  18. calculations are 3,579,545 clocks/second on an NTSC machine and 3,546,895 
  19. clocks/second on a PAL machine.  An example of an integer calculation using 
  20. these values follows.
  21.  
  22. #define NTSC_CLOCK (3579545)
  23. #define PAL_CLOCK  (3546895)
  24.  
  25. ULONG clock, clockx100, periodx10, period, hertzx10, sampleBytes;
  26.  
  27. /* Check GfxBase->DisplayFlags and set clock to appropriate value
  28.  * Set hertzx10 to 10 * desired frequency in hertz
  29.  * Set sampleBytes to number of bytes in the one cycle waveform sample
  30.  */
  31.  
  32. clockx100 = 100 * clock;
  33. periodx10 = (clockx100 / hertzx10) / sampleBytes;
  34. /* round off */
  35. period = (periodx10 + 5) / 10;
  36.  
  37.      
  38.  
  39.